﻿using System;
using System.Linq;
using System.Reflection;
using Castle.DynamicProxy;

namespace Yama.MVC.MonoRail.Extensions
{
    public class SelectactionInterceptorSelector : IInterceptorSelector
    {
        #region Implementation of IInterceptorSelector

        public IInterceptor[] SelectInterceptors(Type type, MethodInfo method, IInterceptor[] interceptors)
        {
            if(method.Name.Equals("SelectAction"))
                return interceptors;

            return interceptors.Where(i => !(i is SelectActionInterceptor)).ToArray();
        }

        #endregion
    }
}